package com.dd.dus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dd.dc.entity.users.DLevelInfo;
import com.dd.dus.mapper.DLevelInfoMapper;
import com.dd.dus.service.IDLevelInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * VIP等级表 服务实现类
 * </p>
 *
 * @author JueDream
 * @since 2021-03-12
 */
@Service
public class DLevelInfoServiceImpl extends ServiceImpl<DLevelInfoMapper, DLevelInfo> implements IDLevelInfoService {

    @Autowired
    DLevelInfoMapper levelInfoMapper;

    @Override
    public Page<DLevelInfo> queryLevelList(Integer page, Integer limit, String levelName) {
        Page<DLevelInfo> levelIPage = new Page<>(page, limit);
        LambdaQueryWrapper<DLevelInfo> queryWrapper = new LambdaQueryWrapper<DLevelInfo>();
        queryWrapper.like(DLevelInfo::getLevelName, levelName);
        levelIPage = levelInfoMapper.selectPage(levelIPage, queryWrapper);
        levelIPage.setTotal(levelIPage.getRecords().size());
        return levelIPage;
    }

    @Override
    public Integer insert(DLevelInfo levelInfo) {
        return levelInfoMapper.insert(levelInfo);
    }

}
